<template>
  <div>
    <el-form label="年龄" prop="age">
      <el-input type="age" placeholder="请输入年龄" v-model="number" style="width: 120px" id="aged"></el-input>
      <el-button @click="submit">提交</el-button>
    </el-form>

    <el-table :data="tableData" border style="width: fit-content">
      <el-table-column
        fixed
        prop="age"
        label="年龄"
        width="150">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="120">
      </el-table-column>
      <el-table-column
        prop="province"
        label="省份"
        width="120">
      </el-table-column>
      <el-table-column
        prop="city"
        label="市区"
        width="120">
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
          <el-button type="text" size="small" @click="deleteClick(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
  export default {
    data () {
      // {input:''
      // document.getElementsByid('aged')[0].value
      //     this.aged
      //
      // }
      return {
        tableData: [{
          age: '20',
          name: '王小虎',
          province: '上海',
          city: '普陀区',
        }, {
          age: '21',
          name: '王小虎',
          province: '上海',
          city: '普陀区',
        }, {
          age: '22',
          name: '王小虎',
          province: '上海',
          city: '普陀区',
        }, {
          age: '23',
          name: '王小虎',
          province: '上海',
          city: '普陀区',
        }],
        number: ''
      }
    },
    methods: {
      handleClick (row) {
        console.log(row)
        alert(row)
      },
      submit () {
        alert(this.number)
      },
      deleteClick (row) {
        for (var i = 0; i < this.tableData.length; i++) {
          if (this.tableData[i] === row) {
            this.tableData.splice(i, 1)
          }
        }
      }
    }
  }
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
////
